const defaultState={
    inputValue:'',
    list:[]
}
const reducer=(state=defaultState,action)=>{
    if(action.type==='CHANGE_INPUT'){
        const newState=JSON.parse(JSON.stringify(state))
        newState.inputValue=action.value
        return newState
    }
    if(action.type==='ADD_ITEM'){
        const newState=JSON.parse(JSON.stringify(state))
        newState.list.push(newState.inputValue)
        newState.inputValue=''
        return newState
    }
    return state
}
export default reducer